<template>
	<!-- 普通弹窗 -->
	<uni-popup ref="popup" type="center">
		<view class="pop-box">
			<view v-if="showTitle" class="flex item-center flex-col">
				<view class="mb-8 title">解除关联</view>
				<view>解除需上级经纪人同意</view>
			</view>
			<textarea class="text-area" name="" v-model="refuseReason" placeholder="请输入解除说明" id="" cols="20" rows="10"></textarea>
			<view class="tip-box" v-show="tipShow">请输入解除说明</view>
			<view class="btn-box flex item-center">
				<view class="btn-sty" @click="showPop(false)">取消</view>
				<view class="btn-sty submit-btn" @click="submit()">确定</view>
			</view>
		</view>
	</uni-popup>
</template>

<script setup>
	import {
		ref,
		onMounted
	} from 'vue'
	const props = defineProps({
		showTitle: {
			type: Boolean,
			default: false
		}
	})
	const popup = ref()
	const tipShow = ref(false)
	const refuseReason = ref('')
	const emits = defineEmits(['onSubmit'])
	const showPop = (value) => {
		tipShow.value = false
		if (value) {
			popup.value && popup.value.open('center')
			refuseReason.value = ''
		} else {
			popup.value && popup.value.close()
		}
	}
	const submit = () => {
		if(!refuseReason.value){
			tipShow.value = true
			return
		}
		emits('onSubmit',{refuseReason:refuseReason.value})
		showPop(false)
	}
	defineExpose({
		showPop
	})
</script>

<style lang="scss" scoped>
	.pop-box{
		width: 320px;
		// height: 188px;
		border-radius: 12px;
		background-color: #ffffff;
		box-shadow: 0px -0.5px 0px 0px rgba(0, 0, 0, 0.1);
		padding-top: 14px;
		.title{
			font-weight: 600;
			font-size: 16px;
			color: #333333;
		}
		.text-area{
			margin: 14px auto 0 auto;
			border: 1px solid rgba(51, 51, 51, 0.3);
			border-radius: 8px;
			width: 280px;
			box-sizing: border-box;
			padding: 10px;
			font-size: 12px;
		}
		.tip-box{
			height: 20px;
			line-height: 20px;
			color: rgba(250, 69, 67, 1);
			font-size: 12px;
			width: 280px;
			margin: 6px auto 10px auto;
		}
		.btn-box{
			border-top: 1px solid rgba(51, 51, 51, 0.3);
			margin-top: 10px;
			.btn-sty{
				width: 50%;
				box-sizing: border-box;
				color: rgba(51, 51, 51, 0.6);
				font-family: PingFang SC;
				font-size: 16px;
				font-weight: 400;
				line-height: 44px;
				text-align: center;
				&.submit-btn{
					border-left: 1px solid rgba(51, 51, 51, 0.3);
					color: rgba(250, 69, 67, 1);
				}
			}
		}
	}
</style>